home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Information / Programming / Stuart's Tech Notes / AppleTalk Zone List.c < prev    next >
Encoding:
Text File  |  1994-12-12  |  8.0 KB  |  52 lines  |  [TEXT/R*ch]

  1. /* (C) 1993 Stuart Cheshire <cheshire@cs.stanford.edu>
  2.  
  3. This sample code can be used to obtain a list of AppleTalk Zones on the
  4. network. It uses an efficient sorting algorithm to sort a large number
  5. zone names into alphabetical order in an acceptable length of time.
  6. I'm making this public because a shocking number of programs, like MacTCP,
  7. Shiva Net Manager, Spectre Supreme etc. are unable to do this. The Stanford
  8. network has over 200 zones, and on a Mac SE it takes *over a minute* just
  9. to open the MacTCP Control Panel!
  10.  
  11. MAX_ZONES is set to 1000 by default, which should be enough for most networks.
  12.  
  13. You should create a List Manager list, and then call getzonelist to fill it.
  14.  
  15. eg.
  16.     static Rect initial_list = { 0,0,0,1 };
  17.     static Point list_cell_size = { 0,0 };
  18.     
  19.     GetDItem(modaldialog, zonelist_item, &di_type, &di_handle, &di_box);
  20.                                     // Read useritem bounds from DITL
  21.     di_box.right -= 15;                // Make room for the vertical scroll bar
  22.     zonelist = LNew(&di_box, &initial_list, list_cell_size, 0, modaldialog,
  23.         TRUE, FALSE, FALSE, TRUE);    // Create the list
  24.  
  25.  
  26.     LDoDraw(FALSE, zonelist);        // Turn off list drawing
  27.     num_appletalk_zones = getzonelist(zonelist, mydomain.c);
  28.                                     // Get the list of zones    
  29.     pt.h = pt.v = 0;
  30.     LSearch(&myzone.c[1], myzone.c[0], NULL, &pt, zonelist);
  31.     LSetSelect(TRUE, pt, zonelist);    // select home zone as default
  32.     LAutoScroll(zonelist);            // scroll it into view
  33.     LDoDraw(TRUE, zonelist);        // and turn on list drawing again.
  34.  
  35.  
  36. Tab stops are four spaces
  37.  
  38. /*****************************************************************************/
  39.  
  40. #include <AppleTalk.h>
  41. #include <Packages.h>
  42.  
  43. #include "StuTypes.h"
  44. #include "StuAppleTalk.h"
  45.  
  46. /*****************************************************************************/
  47.  
  48. #define atpMaxData     578             // size of buffer for zone names
  49. #define kZIPSocket     6             // the Zone Information Protocol socket
  50. #define kATPTimeOutVal 3             // re-try ATP SendRequest every 3 seconds
  51. #define kATPRetryCount 5             // for five times
  52. #define kGZLCall       0x08000000    // GetZoneL